package org.strieber.fca;

import java.util.ArrayList;
import java.util.List;

public class RuleCompressor {
	
	public RuleCompressor(List<Rule> rules) {
		List<String> workingList = changeListOfRulesToListOfStrings(rules);
		workingList = processIntegration(workingList);
		workingList = processSubstitution(workingList);
	}
	
	// change the list of rules into a list of strings
	private List<String> changeListOfRulesToListOfStrings(List<Rule> rules) {
		List<String> listOfStrings = new ArrayList<String>();
		// do the work here.
		return listOfStrings;
	}
	
	// processIntegration() condenses rules into more complex meta rules
	// List<String> -> List<String>
	// 
	// example:
	// 1:	(A = 1 and B = 2 and C = 1) -> 1
	// 2:	(A = 3 and B = 2 and C = 1) -> 1
	// 3:	(A = 2 and B = 2 and C = 1) -> 1
	// 4:	(A = 1 and B = 2 and C = 2) -> 1
	// 5:	(A = 3 and B = 2 and C = 2) -> 1
	// 6:	(A = 1 and B = 2 and C = 2) -> 1
	// 7:	(A = 3 and B = 3 and C = 1) -> 1
	// 8:	(A = 2 and B = 3 and C = 1) -> 1
	// 9:	(A = 1 and B = 3 and C = 1) -> 1
	// 10:	(A = 3 and B = 3 and C = 2) -> 1
	// 11:	(A = 2 and B = 3 and C = 2) -> 1
	// 12:	(A = 1 and B = 3 and C = 2) -> 1
	// 
	// In to:
	// (A = 1 and B = 2 and (C = 1 or C = 2)) -> 1
	// (A = 3 and B = 2 and (C = 1 or C = 2)) -> 1
	// (A = 2 and B = 2 and (C = 1 or C = 2)) -> 1
	// (A = 3 and B = 3 and (C = 1 or C = 2)) -> 1
	// (A = 2 and B = 3 and (C = 1 or C = 2)) -> 1
	// (A = 1 and B = 3 and (C = 1 or C = 2)) -> 1
	private List<String> processIntegration(List<String> rules) {
		List<String> integratedRules = new ArrayList<String>();
		return integratedRules;
	}
	
	// substitutes less complex rules in for a set of more complex rules
	private List<String> processSubstitution(List<String> rules) {
		List<String> substitutedRules = new ArrayList<String>();
		return substitutedRules;
	}
	
	public static void main(String[] args) {
		// TODO Auto-generated method stub

	}
}